home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / man / matrix.tex < prev    next >
Encoding:
Text File  |  1994-08-05  |  3.2 KB  |  95 lines

  1. \bigskip
  2. \bigskip
  3. {\magonebf  2.4 Real-Valued Matrices (matrix)}
  4.  
  5. An instance of the data type $matrix$ is a matrix of double variables.
  6.  
  7. \def\name{$matrix$}
  8. \def\type{$matrix$}
  9.  
  10. \bigskip
  11. {\bf 1. Creation}
  12.  
  13. \create M (int\ n,\ int\ m)
  14.  
  15.  
  16. creates an instance $M$ of type $matrix$, $M$ is initialized to the $n \times m$
  17. - zero matrix.
  18.  
  19.  
  20. \bigskip
  21. {\bf 2. Operations on a matrix M}
  22.  
  23. \medskip
  24. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  25. \+\op int     dim1 {}  
  26.                            { returns $n$, the number of rows of $M$.}
  27. \smallskip
  28. \+\op int     dim2 {}  
  29.                            { returns $m$, the number of cols of $M$.}
  30. \smallskip
  31. \+\op vector  row {int\ i}  
  32.                            { returns the $i$-th row of $M$ (an $m$-vector).}
  33. \+\nop                     { \precond  $0 \le i \le n-1$.}
  34. \smallskip
  35. \+\op vector  col {int\ i}  
  36.                            { returns the $i$-th column of $M$ (an $n$-vector).}
  37. \+\nop                     { \precond  $0 \le i \le m-1$.}
  38. \smallskip
  39. \+\op matrix  trans {}     
  40.                            { returns  $M^T$ ($m\times n$ - matrix). }
  41. \smallskip
  42. \+\op double    det {}       
  43.                            { returns the determinant of $M$.}
  44. \+\nop                     { \precond  $M$ is quadratic.}
  45. \smallskip
  46. \+\op matrix  inv {}       
  47.                            { returns the inverse matrix of $M$. }
  48. \+\nop                     { \precond  $M$.det() $\neq$ 0.}
  49. \smallskip
  50. \+\op vector  solve {vector\ b}  
  51.                            { returns vector $x$ with $M\cdot x = b$. }
  52. \+\nop                     { \precond $M$.dim1() = $M$.dim2() = $b$.dim()}
  53. \+\nop                     { and $M$.det() $\neq$ 0.}
  54. \medskip
  55. \+\opf double\&  {int\ i,\ int\ j}        
  56.                                  {returns $M_{i,j}$.}
  57. \+\nop                           {\precond $0\le i\le n-1$ and $0\le j\le m-1$.}
  58.  
  59. \smallskip
  60. \+\opb matrix    +  M_1  
  61.                                  {Addition}
  62. \+\nop                           {\precond $M$.dim1() = $M_1$.dim1() and}
  63. \+\nop                           { $M$.dim2() = $M_1$.dim2().}
  64. \smallskip
  65. \+\opb matrix    -  M_1  
  66.                                  {Subtraktion}
  67. \+\nop                           {\precond $M$.dim1() = $M_1$.dim1() and}
  68. \+\nop                           { $M$.dim2() = $M_1$.dim2().}
  69. \smallskip
  70. \+\opb matrix    *  M_1   
  71.                                  {Multiplication}
  72. \+\nop                           {\precond $M$.dim2() = $M_1$.dim1().}
  73. \smallskip
  74. \+\opb matrix     *  r     
  75.                                  {Multiplication with double}
  76. \smallskip
  77. \+\opb vector     *  v     
  78.                                  {Multiplication with vector}
  79. \+\nop                           {\precond $M$.dim2() = $v$.dim().}
  80. \medskip
  81. \+\ops ostream\&  << O       
  82.                                  {writes matrix $M$ to the output stream $O$}
  83. \smallskip
  84. \+\ops istream\&  >> I       
  85.                                  {reads matrix $M$ from the input stream $I$}
  86.  
  87. \bigskip
  88. {\bf 3. Implementation }
  89. \medskip
  90. Data type $matrix$ is implemented by two-dimensional arrays of double numbers. 
  91. Operations det, solve, and inv take time $O(n^3)$, dim1, dim2, row, and col 
  92. take constant time, all other operations take time $O(nm)$.  
  93. The space requirement is $O(nm)$.
  94.  
  95.